package com.ls.fw.mvc.springmvc.support.convert;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 自定义返回JSON 数据格中日期格式化处理 
 * 
 * @author lisheng
 * @date 2015年9月9日 下午10:36:52
 * @version V1.0
 */
public class CustomDateHHmmSerializer extends JsonSerializer<Date> {  

    @Override  
    public void serialize(Date value,   
            JsonGenerator jsonGenerator,   
            SerializerProvider provider)  
            throws IOException, JsonProcessingException {  
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
        jsonGenerator.writeString(sdf.format(value));  
    }  
}  